#pragma once

class Tank
{
protected:
	SolidBrush green{ 0xff11ee11 };
	Pen border{ 0xffff0000,1 };

	int direction;																//current direction of the tank
	int life;																	//current life of the tank
	int maxlife;																//max life of the tank
	double x, y;																//current position of the tank
	Image * picSet[4];															//picture of 4 directions
	std::wstring name;
	int width;																	//width of the tank
	int height;																	//height of the tank

	int power = 0;																//level of power

public:
	Tank(const std::wstring & name, double x, double y, int dir, int life);		//name is the picture name of the tank(extensions excluded)
	virtual ~Tank();

	//virtual void update(double dtime);
	void draw(Graphics * graphics);												//draw the tank
	void move(int deltax, int deltay);											//move by(x,y)
	//void launch(const std::wstring & name, int v, const std::wstring & sname = L"Linear", int lifespan = 100000);	//launch a bullet with a bullet name
	//void launch()
	Rect getRect();																//get the bounding box of the tank
	Point getPoint();
	void changeDir(int direction);												//change direction without moving
	int bleed(int amount);														//bleed, returns the current life
	int getLife();																//return the current life
	bool collide(Point pt);														//collide with a point?
	bool collide(Rect rc);														//collide with a rect?
	void powerby(int delta);
	int getPower() { return power; }
};

//class HeroTank :public Tank
//{
//private:
//
//public:
//	HeroTank(const std::wstring & name, double x, double y, int dir, int life);
//	~HeroTank();
//
//	//void launch(const std::wstring & name, int v) override;
//};

struct tagEnemy
{
	tagBullet bulletInfo;
	std::wstring bname;
	std::wstring picname;
	std::wstring sname;
	int direction;
	int life;
	int v;
	int shootinterval;
};

class EnemyTank :public Tank
{
private:
	//double v;
	double vx, vy;
	double time = 0;
	/*tagBullet bullet;
	std::wstring bname;*/
	tagEnemy info;
	EnemyStrategy * s;

public:
	//EnemyTank(const std::wstring & name, double x, double y, int dir, int v, int life, const std::wstring & bname, const tagBullet & bullet);
	EnemyTank(const tagEnemy & enemy, double x, double y);
	~EnemyTank();

	void update(double dtime);
	//void launch(const std::wstring & name, int v) override;
	void launch();
};

class HeroTank :public Tank
{
private:
	int bomb = 10;
	int v = 600;

public:
	HeroTank(const std::wstring & name, double x, double y, int dir, int life);
	~HeroTank();

	//void launchBomb(int v, const std::wstring & sname = L"Linear", int lifespan = 100000);
	void launch(const std::wstring & bname, const tagBullet & bullet);
	int getBomb();
	void bombBy(int count);
	void update(double dtime);
};